/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.adrs;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.model.Visita;
import br.ufc.quixada.adrs.util.Msg;
import br.ufc.quixada.adrs.util.UtilAdrs;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Caio
 */
public class CmdEditarQuestionarioSanitario implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        Visita v = (Visita) session.getAttribute("visita");
        v.setData(UtilAdrs.treatToDate(request.getParameter("data")));
        if (v.getData() == null) {
            session.setAttribute("erro", Msg.INPUT_ERROR_WRONG_VISITA_DATE_FORMAT);
            return "/adrs/adrs_add_visita.jsp";
        }

        session.setAttribute("visitaAEditar", v);
        return "/adrs/adrs_add_quest_sanitario.jsp";
    }
}
